package com.example.androidpattern.bridge;

import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.androidpattern.AppConstant;
import com.example.androidpattern.EMTagHandler;
import com.example.androidpattern.R;
import com.example.androidpattern.bridge.classes.HandBag;
import com.example.androidpattern.bridge.classes.RedColor;
import com.example.androidpattern.bridge.classes.Wallet;
import com.example.androidpattern.bridge.classes.YellowColor;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class BridgeActivity extends AppCompatActivity {

    private static final String TAG = "BridgeActivity";
    @BindView(R.id.btn_bridge)
    Button btnBridge;
    @BindView(R.id.tv_bridge_info)
    TextView tvBridgeInfo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bridge);
        ButterKnife.bind(this);

        setTitle("桥接模式");
        tvBridgeInfo.setText(EMTagHandler.fromHtml(AppConstant.BRIDGE_DEFINE));
    }

    @OnClick(R.id.btn_bridge)
    public void onViewClicked() {
        HandBag handBag = new HandBag();
        handBag.setColor(new RedColor());
        Log.d(TAG, "onViewClicked: " + handBag.getName());

        Wallet wallet = new Wallet();
        wallet.setColor(new YellowColor());
        Log.d(TAG, "onViewClicked: " + wallet.getName());
    }
}
